/* 基础样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

body {
    background-color: #f8f9fa;
    height: 100vh;
    overflow: hidden;
    color: #333;
    line-height: 1.6;
}

/* 主容器 */
.container {
    display: flex;
    height: 100vh;
    position: relative;
    overflow: hidden;
}

/* 侧边栏 */
.sidebar {
    width: 260px;
    background-color: #fff;
    border-right: 1px solid #e6e6e6;
    display: flex;
    flex-direction: column;
    padding: 16px;
    overflow-y: auto;
    z-index: 10;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.05);
    position: relative;
    transition: width 0.3s ease, transform 0.3s ease;
}

/* 侧边栏收缩按钮 */
.sidebar-toggle {
    position: absolute;
    right: 10px;
    top: 15px;
    width: 30px;
    height: 30px;
    background-color: #fff;
    border: 1px solid #e6e6e6;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 20;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.sidebar-toggle:hover {
    background-color: #f0f4f8;
    transform: scale(1.05);
}

.sidebar-toggle:active {
    transform: scale(0.95);
}

.sidebar-toggle i {
    font-size: 18px;
    color: #666;
    transition: transform 0.3s ease;
}

/* 添加两个独立的容器 */
.sidebar-expanded-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
}

.sidebar-collapsed-container {
    display: none;
    flex-direction: column;
    align-items: center;
    width: 100%;
    height: 100%;
}

/* 收缩状态 */
.sidebar.collapsed {
    width: 60px;
    padding: 16px 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    transform: translateX(0);
}

.sidebar.collapsed .sidebar-expanded-container {
    display: none;
}

.sidebar.collapsed .sidebar-collapsed-container {
    display: flex;
}

.sidebar.collapsed .sidebar-toggle {
    position: relative;
    right: 0;
    top: 0;
    margin: 15px auto;
    order: 2;
}

.sidebar.collapsed .logo {
    padding: 0 0 15px;
    justify-content: center;
    margin-bottom: 5px;
    order: 1;
    border-bottom: none;
}

.sidebar.collapsed .new-chat-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 15px auto 0;
    order: 3;
}

.sidebar.collapsed .logo h1 {
    display: none;
}

.sidebar.collapsed .new-chat-btn i {
    margin-right: 0;
}

.sidebar.collapsed .new-chat-btn span {
    display: none;
}

.sidebar.collapsed .sidebar-toggle i {
    transform: none;
}

.sidebar.collapsed .history-list {
    display: none;
    order: 4;
}

.logo {
    padding: 0 10px 20px;
    border-bottom: 1px solid #f0f0f0;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s ease, padding 0.3s ease;
}

.logo h1 {
    font-size: 1.3rem;
    color: #1a73e8;
    font-weight: 600;
    text-align: center;
    transition: display 0.3s ease;
}

.logo img {
    height: 28px;
    margin-right: 10px;
    transition: margin 0.3s ease;
}

.sidebar.collapsed .logo img {
    margin-right: 0;
}

.new-chat-btn {
    background-color: #1a73e8;
    color: white;
    border: none;
    border-radius: 20px;
    padding: 12px 20px;
    margin: 5px 0 20px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(26, 115, 232, 0.2);
}

.new-chat-btn:hover {
    background-color: #1565c0;
    box-shadow: 0 4px 8px rgba(26, 115, 232, 0.3);
}

.new-chat-btn:active {
    transform: translateY(1px);
}

.new-chat-btn i {
    margin-right: 8px;
    font-size: 1.1rem;
}

.history-list {
    flex-grow: 1;
    overflow-y: auto;
    padding-right: 5px;
}

.history-list h3 {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 12px;
    padding: 0 10px;
    font-weight: 500;
}

.history-list ul {
    list-style: none;
}

.history-item {
    padding: 12px 15px;
    margin: 5px 0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.history-item:hover {
    background-color: #f0f4f8;
}

.history-item.active {
    background-color: #e3f2fd;
    border-left: 3px solid #1a73e8;
}

.history-item .history-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-grow: 1;
    color: #444;
}

.history-item .history-date {
    font-size: 0.75rem;
    color: #999;
    margin-left: 5px;
}

.history-item .delete-btn {
    opacity: 0;
    transition: opacity 0.2s;
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 3px 6px;
    border-radius: 4px;
    margin-left: 8px;
}

.history-item:hover .delete-btn {
    opacity: 1;
}

.history-item .delete-btn:hover {
    color: #d32f2f;
    background-color: rgba(211, 47, 47, 0.1);
}

/* 主内容区域 */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #fff;
    position: relative;
    overflow: hidden;
    transition: margin-left 0.3s ease;
    width: calc(100% - 260px); /* 固定宽度，减去侧边栏宽度 */
    margin-left: 0;
}

/* 当侧边栏收缩时，主内容区域调整 */
.sidebar.collapsed + .main-content {
    width: calc(100% - 60px); /* 侧边栏收缩时调整宽度 */
    margin-left: 0;
    transition: width 0.3s ease, margin-left 0.3s ease;
}

.chat-area {
    flex-grow: 1;
    overflow-y: auto;
    padding: 25px 20px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    scroll-behavior: smooth;
}

.chat-area::-webkit-scrollbar {
    width: 5px;
}

.chat-area::-webkit-scrollbar-track {
    background: transparent;
}

.chat-area::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 10px;
}

.chat-area::-webkit-scrollbar-thumb:hover {
    background: #ccc;
}

.user-message, .ai-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: fadeIn 0.3s ease-out forwards;
}

.user-message {
    align-self: flex-end;
}

.ai-message {
    align-self: flex-start;
}

.message-content {
    padding: 14px 18px;
    border-radius: 15px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    line-height: 1.6;
}

.user-message .message-content {
    background-color: #e3f2fd;
    color: #0d47a1;
    border-bottom-right-radius: 4px;
}

.ai-message .message-content {
    background-color: #f5f5f5;
    color: #212121;
    border-bottom-left-radius: 4px;
}

.message-content p {
    margin-bottom: 8px;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-time {
    font-size: 0.7rem;
    color: #999;
    margin-top: 5px;
    align-self: flex-start;
}

.user-message .message-time {
    align-self: flex-end;
}

/* 图片展示区 */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 12px;
    margin-top: 15px;
}

.image-grid.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.image-grid.grid-4 {
    grid-template-columns: repeat(2, 1fr);
}

@media (min-width: 992px) {
    .image-grid.grid-4 {
        grid-template-columns: repeat(4, 1fr);
    }
}

.image-item {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    aspect-ratio: 1;
    background-color: #f0f0f0;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
}

.image-item:hover {
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.image-item:hover img {
    transform: scale(1.05);
}

.image-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f0f0f0;
    border-radius: 10px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top-color: #1a73e8;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 底部输入区域 */
.input-area {
    position: relative;
    background-color: #fff;
    border-top: 1px solid #e6e6e6;
    padding: 15px 20px 15px 20px;
    display: flex;
    align-items: center;
    min-height: 90px;
    max-height: 220px;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.input-area textarea {
    flex: 1;
    resize: none;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px 50px 12px 15px;
    min-height: 70px;
    max-height: 180px;
    overflow-y: auto;
    line-height: 1.5;
    font-size: 1rem;
    outline: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: border-color 0.3s, box-shadow 0.3s;
    padding-bottom: 40px;
}

.input-area textarea:focus {
    border-color: #1a73e8;
    background-color: #fff;
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.2);
}

.input-area textarea::placeholder {
    color: #aaa;
}

.send-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: #34a853;
    color: white;
    border: none;
    margin-left: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(52, 168, 83, 0.2);
    flex-shrink: 0;
}

.send-btn:hover {
    background-color: #2d8e49;
    box-shadow: 0 4px 8px rgba(52, 168, 83, 0.3);
}

.send-btn:active {
    transform: scale(0.95);
}

.send-btn.loading::before {
    content: "";
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s linear infinite;
    background: none;
    position: absolute;
}

.send-btn.loading i {
    display: none;
}

/* 图片预览模态框 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.5);
}

.modal-content img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    display: block;
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 15px;
    color: white;
    font-size: 30px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    transition: all 0.2s ease;
}

.close-modal:hover {
    background-color: rgba(0, 0, 0, 0.8);
}

.download-btn {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background-color: #34a853;
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.download-btn:hover {
    background-color: #2d8e49;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.download-btn::before {
    content: "";
    display: block;
    width: 16px;
    height: 16px;
    margin-right: 8px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23ffffff'%3E%3Cpath d='M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
}

/* 欢迎屏幕 */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 20px;
    text-align: center;
    color: #555;
}

.welcome-screen h2 {
    font-size: 1.8rem;
    color: #1a73e8;
    margin-bottom: 1rem;
    font-weight: 500;
}

.welcome-screen p {
    font-size: 1.1rem;
    max-width: 600px;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.welcome-screen .examples {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
    max-width: 900px;
    width: 100%;
    margin-top: 20px;
}

.example-card {
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 10px;
    border: 1px solid #e0e0e0;
    cursor: pointer;
    transition: all 0.2s ease;
}

.example-card:hover {
    background-color: #e3f2fd;
    border-color: #1a73e8;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.example-card h3 {
    font-size: 1.1rem;
    margin-bottom: 8px;
    color: #1a73e8;
}

.example-card p {
    font-size: 0.9rem;
    color: #666;
    margin: 0;
}

/* 移动端响应式设计 */
@media screen and (max-width: 768px) {
    .container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        max-height: 50vh;
        border-right: none;
        border-bottom: 1px solid #e6e6e6;
        padding: 10px;
    }
    
    .sidebar-toggle {
        right: 20px;
        top: 15px;
    }
    
    .sidebar.collapsed {
        width: 100%;
        padding: 10px;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
    
    .sidebar.collapsed .logo,
    .sidebar.collapsed .sidebar-toggle,
    .sidebar.collapsed .new-chat-btn {
        margin: 0 5px;
        order: unset;
    }
    
    .main-content {
        margin-left: 0;
        padding-left: 0;
        border-radius: 0;
    }
    
    .sidebar.collapsed + .main-content {
        margin-left: 0;
    }
    
    .chat-area {
        padding: 15px;
    }
    
    .user-message, .ai-message {
        max-width: 90%;
    }
    
    .welcome-screen h2 {
        font-size: 1.5rem;
    }
    
    .welcome-screen p {
        font-size: 1rem;
    }
    
    .input-area {
        padding: 10px 15px;
    }
    
    .input-area textarea {
        padding: 12px 15px;
    }
    
    .send-btn {
        width: 44px;
        height: 44px;
    }
    
    .modal-content {
        width: 95%;
    }
}

/* 动画效果 */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 工具提示 */
.tooltip {
    position: relative;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

.tooltip:hover::after {
    opacity: 1;
    visibility: visible;
    bottom: calc(100% + 10px);
}

/* 加载动画 */
.loading-chat {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #666;
}

.loading-chat .loading-spinner {
    margin-bottom: 15px;
}

.loading-chat p {
    font-size: 0.9rem;
}

/* 示例卡片点击状态 */
.example-card:active {
    transform: scale(0.98);
}

/* 添加模式选择器样式 */
.mode-selector {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 15px 0;
    overflow: hidden;
}

.mode-btn {
    width: 100%;
    padding: 12px 8px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    border: none;
    background-color: transparent;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #555;
    border-radius: 8px;
}

.mode-btn i {
    margin-right: 10px;
    font-size: 18px;
}

.mode-btn.active {
    background-color: #1a73e8;
    color: white;
}

.mode-btn:hover:not(.active) {
    background-color: rgba(26, 115, 232, 0.1);
}

/* 深度思考开关 */
.reasoning-toggle {
    display: flex;
    align-items: center;
    position: absolute;
    left: 25px;
    bottom: 20px;
    z-index: 20;
    background-color: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    padding: 6px 12px;
    color: #555;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.reasoning-toggle:hover {
    background-color: #f0f4f8;
    border-color: #c0c0c0;
}

.reasoning-toggle.active {
    color: #1a73e8;
    background-color: #e3f2fd;
    border-color: #1a73e8;
}

.reasoning-toggle span {
    font-size: 14px;
    font-weight: 500;
    margin-left: 5px;
}

/* 移除开关样式 */
.switch {
    display: none;
}

.slider {
    display: none;
}

.reasoning-toggle i {
    font-size: 16px;
    color: inherit;
}

/* 推理内容样式 */
.reasoning-box {
    margin-top: 15px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
}

.reasoning-title {
    padding: 10px 15px;
    background-color: #f5f5f5;
    font-weight: 500;
    display: flex;
    align-items: center;
    cursor: pointer;
    border-bottom: 1px solid #e0e0e0;
}

.reasoning-title i {
    margin-right: 8px;
    color: #1a73e8;
}

.reasoning-title:hover {
    background-color: #e3f2fd;
}

.reasoning-title:after {
    content: '\25BC';
    margin-left: auto;
    font-size: 12px;
    color: #777;
    transition: transform 0.3s ease;
}

.reasoning-title.expanded:after {
    transform: rotate(180deg);
}

.reasoning-content {
    padding: 15px;
    font-size: 14px;
    line-height: 1.6;
    background-color: #fafafa;
    white-space: pre-wrap;
    max-height: 500px;
    overflow-y: auto;
}

.reasoning-content::-webkit-scrollbar {
    width: 5px;
}

.reasoning-content::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.reasoning-content::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 5px;
}
/* 对话模式下图片隐藏 */
.chat-mode .image-grid {
    display: none;
}

/* 聊天头部样式 */
.chat-header {
    padding: 15px 20px;
    border-bottom: 1px solid #e6e6e6;
    display: flex;
    align-items: center;
    background-color: #fff;
    z-index: 5;
}

.chat-title {
    font-size: 18px;
    font-weight: 500;
    color: #333;
    margin: 0;
}
